$(function(){
	/*疫苗新闻列表*/
	var pages;
	ym.ajax({
		url:'/article/getMenuArticle',
		param:{
				menuTagId :5
			},
		success:function(data){
			var html = "";
			var html2 = "";
			console.log(data.obj);
			if(data.res ==1){
				pages = data.obj.pageNum;
				if(data.obj.results != null){
					for(var i=0;i<data.obj.results.length;i++){
						var res = data.obj.results[i];
						html += '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left yimiaonews" id="'+res.articleId+'">'
									html +='<div class=" am-u-sm-8 am-list-main w72">'
									html +='<h3 class="am-list-item-hd twospace"><a href="javascript:void()" class="">'+res.articleTitle+'</a></h3>'
									html +='<ul class="activity">'
										html +='<li><img src="../img/eyes.png"><span class="am-margin-left-xs">'+res.readNumber+'</span></li>'
										html +='<li><img src="../img/comments.png"><span class="am-margin-left-xs">'+res.replyCount+'</span></li>'
									html +='</ul>'
									html +='</div>'
									html +='<div class="am-u-sm-3 am-list-thumb">'
										html +='<a href="javascript:void()" class="">'
											html +='<img src="'+res.articleCoverUlr+'" alt="零星！"/>'
							      		html +='</a>'
							      	html +='</div>'
							       html +='</li>';	
					}
					$('.news').append(html);
				}else{
					html = '<li class="am-text-center"><img style="height:150px" src="../img/no.jpg"></li>';
					$('.news').append(html);
				}
				
				if(data.obj.totalRecord > 5){
					$('.more').removeClass('none');
				}
				
			}else{console.log("数据获取失败！")}
		}
	});
	
	/*点击查看更多*/
	$('body').on('click','.more',function(){
		$("#my-modal-loading").modal('open');
		pages = pages + 1;
		ym.ajax({
			url:'/article/getMenuArticle',
			param:{
					menuTagId :5,
					pageNum:pages,
				},
			success:function(data){
				setTimeout(function(){
					$("#my-modal-loading").modal('close');
				},300)
				var html = "";
				var html2 = "";
				console.log(data.obj);
				if(data.res ==1){
					pages = data.obj.pageNum;
					for(var i=0;i<data.obj.results.length;i++){
						var res = data.obj.results[i];
						html = '<li class="am-g am-list-item-desced am-list-item-thumbed am-list-item-thumb-left yimiaonews" id="'+res.articleId+'">'+
									'<div class=" am-u-sm-8 am-list-main w72">'+
									'<h3 class="am-list-item-hd"><a href="javascript:void()" class="">'+res.articleTitle+'</a></h3>'+
									//'<div class="am-list-item-text">'+res.articleDescribe+'</div>'+
									'<ul class="activity">'+
										'<li><img src="../img/eyes.png"><span class="am-margin-left-xs">'+res.readNumber+'</span></li>'+
										'<li><img src="../img/comments.png"><span class="am-margin-left-xs">'+res.replyCount+'</span></li>'+
									'</ul>'+
									'</div>'+
									'<div class="am-u-sm-3 am-list-thumb">'+
										'<a href="javascript:void()" class="">'+
											'<img src="'+res.articleCoverUlr+'" alt="零星！"/>'
							      		'</a>'+
							      	'</div>'+
							       	'</li>';	
						$('.news').append(html);
					}
					if(data.obj.results.length < 5){
						$('.more').html('');
						$('.more').html('<p>到底啦</p>');
					}
					
				}else{console.log("数据获取失败！")}
			}
		});
	})
	
	/*疫苗新闻的点击事件*/
	$('body').on('click','.yimiaonews',function(){
		var id = $(this).attr('id');
		ym.ajax({
			url:'/article/updateArticleReadNumber',
			type:'post',
			param:{ articleId:id},
			success:function(data){
				if(data.res ==1){
					console.log("数据获取成功跳转页面！")
				}else{console.log("数据获取失败！")}
				window.location.href='yimiaoxinwenXq.html?articleId='+id;
			}
		});
	})
})